1. Field of the Invention
This disclosure generally relates to techniques for converting between numerical representations on a computer system. More specifically, this disclosure relates to techniques for converting binary values into binary-coded-centimal values.
2. Related Art
Computers can store numbers in a range of different encodings. For instance, while a binary (or base-2) numeral system is used internally by many modern computers, alternative formats may also provide some advantages. For example, a binary-coded decimal (BCD) format uses binary sequences to represent decimal digits (e.g., using four bits to represent the decimals 0-9). Benefits of the BCD format include easy conversion to a human-readable format and the ability to store decimal quantities precisely. More specifically, in some instances decimal-based formats can express some decimal quantities more precisely than binary or floating-point binary formats, and hence continue to be favored for some financial and industrial environments.
Because decimal operations are relatively uncommon, processors often perform decimal operations in software instead of in specialized hardware. However, because performing such operations in software is typically much slower than native binary computational operations, some systems improve the performance of decimal operations by first converting decimal values to binary values, using binary computational circuits to perform operations on the binary values, and then converting the results back into decimal values. Such conversions have the potential to speed up decimal computational operation, but can result in substantial conversion overhead.
Hence, what is needed are techniques for converting between binary and decimal encodings without the above-described problems.